import glob
import logging.handlers
from os.path import dirname, abspath

# 项目根目录
BASE_DIR = dirname(dirname(abspath(__file__)))


class Logger_Demo:
    def __init__(self):
        self._logger = logging.getLogger("myLogger")
        # if not self._logger:
        # 2. 设置日志等级
        self._logger.setLevel(logging.INFO)
        # 3. 设置format对象
        self.formatter = logging.Formatter("%(asctime)s %(levelname)s [%(filename)s %(funcName)s %(lineno)d] %(message)s")

        self.t = logging.StreamHandler()
        # 4.2 设置终端日志模式
        self._logger.addHandler(self.t)

    def get_log(self):
        # 1. 获取一个logger对象
        return self._logger

    def clear(self):
        self._logger.removeHandler(self.t)